package cz.tomasdvorak.cars.wicket.components.breadcrumbs;

import cz.tomasdvorak.cars.pages.BasePage;
import org.apache.wicket.Page;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;

import java.io.Serializable;

public class BreadcrumbItem implements Serializable {
    private final IModel<String> title;
    private final Class<? extends BasePage> page;
    private final Page pageInstance;

    public BreadcrumbItem(IModel<String> title) {
        this(title, null, null);
    }

    public BreadcrumbItem(String title) {
        this(new Model<String>(title), null, null);
    }

    public BreadcrumbItem(String title, Page pageInstance) {
       this(new Model<String>(title), null, pageInstance);
    }

    public BreadcrumbItem(IModel<String> title, Class<? extends BasePage> page) {
       this(title, page, null);
    }

    public BreadcrumbItem(IModel<String> title, Class<? extends BasePage> page,  Page pageInstance) {
        if(title == null) {
            throw new NullPointerException("Title cannot be null");
        }
        this.title = title;
        this.page = page;
        this.pageInstance = pageInstance;
    }

    public IModel<String> getTitle() {
        return title;
    }

    public Class<? extends BasePage> getPage() {
        return page;
    }

    public Page getPageInstance() {
        return pageInstance;
    }
}
